<?php 
class Request_a_quote extends Controller{
	
	function  Request_a_quote(){
        parent::Controller();
        $this->load->library('session');
	    if($this->session->userdata('admin') == '')
    	{
    		 redirect('admin');
    	}
        $this->load->helper(array('form','tiap_helper','html'));
        $this->load->library('form_validation'); 
        $this->load->model(array('request_a_quote_model'));
         
    }
	
	function index(){
	
		$data = array();
    	
		 $page = (int)$this->uri->segment(4);
		
		$page = ($page == '')?0:$page;
		
	   	$per_page = 15;
    	$data['total_quotes'] = $this->request_a_quote_model->total_quotes();
		// pagination start
		$this->load->library('pagination');
		$config['base_url'] = site_url('admin/request_a_quote/index/');
		$config['total_rows'] = $data['total_quotes'];
		$config['per_page'] = $per_page;
	
		$config['uri_segment'] = 4;

		$this->pagination->initialize($config); 

		$data['pagination'] =  $this->pagination->create_links();
		//pagination end
    	$data['order_by'] = $order_by;
    	
    	
    	$data['quotes_list'] = $this->request_a_quote_model->get_quotes($per_page,$page);
        $data['page']=$page;
    	
		$this->load->view(TEMPLATE_NAME.'/admin/request_a_quote/list',$data);
		
		}
		
		function detail(){
			$data = array();
    	    $quote_id = (int)$this->uri->segment(4);
            $page = (int)$this->uri->segment(5);
            $data['page']=$page;
            $quotes_detail=$this->request_a_quote_model->get_quotes_detail($quote_id );
           $papercolour_id= $quotes_detail['quote_papercolourid'];
           $papersize_id= $quotes_detail['quote_papersizeid'];
           $papername_id= $quotes_detail['quote_paperid'];
           
           	if($papersize_id=='0')
            {
             $paper_size='custom '.$quotes_detail['quote_paperwidth'].' x '.$quotes_detail['quote_paperheight'].' mm';   
              } else{
                
                 $paper_size=$this->request_a_quote_model->get_papersize_format($papersize_id);
              }
            
           //die();
            $data['paper_colour']=$this->request_a_quote_model->get_data_colour($papercolour_id);
             $data['paper_size']=$paper_size;
			 if($quotes_detail['quote_paperid'] != '')
			 {
             	$data['paper_name']=$this->request_a_quote_model->get_papername_format($papername_id);	
			 }
			 else
			 {
				 $data['paper_name'] = $quotes_detail['quote_papername'];
			 }
			$data['quotes_detail']=$quotes_detail;
			$this->load->view(TEMPLATE_NAME.'/admin/request_a_quote/detail',$data);
           
			}
			
		function delete(){
		  
            $quote_id= (int)$this->uri->segment(4);
            $quotes_detail=$this->request_a_quote_model->get_quotes_detail($quote_id );
           $artwork= $quotes_detail['quote_artwork'];
          
        @unlink('./quote_upload/'.$artwork);
         $check= $this->request_a_quote_model->delete_quotes($quote_id);
        
        
     redirect('admin/request_a_quote');
        
		}
		
	}

?>